{include file="common/pc/header" title="$enterpriseModule.module.title - 配置" /}

<style>
    body {
        min-height: calc(90vh);
    }
</style>

{if condition="empty($configGroups)"}
<script>
    $(document).ready(function () {
        layui.use('layer', function () {
            layer.alert("本模块暂无配置项");
        });
    });
</script>
{else/}
<form class="layui-form" action="" method="post" id="config-form">
    {foreach name="configGroups" item="configGroup" key="groupName"}
    <div class="layui-card">
        <div class="layui-card-header">{$groupName}</div>
        <div class="layui-card-body">
            {foreach name="configGroup" key="configKey" item="configItem"}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label" style="width: auto;">{$configItem.title}</label>
                <div class="layui-input-inline layui-input-inline-long">
                    {switch name="configItem.type"}
                    {case value="image"}
                        {php}
                            $w = isset($configItem['param']['width']) ? $configItem['param']['width']:"256px";
                            $h = isset($configItem['param']['height']) ? $configItem['param']['height']:"256px";
                        {/php}
                        {d:up type="image" field="$configKey" value="$configItem.value" w="$w" h="$h"}浏览图片{/d:up}
                    {/case}
                    {case value="radio"}
                        {php}
                            $options = $configItem['param']['options'];
                            if(is_string($options)) {
                                $options = json_decode($options, true);
                            }
                        {/php}
                        {foreach name="options" item="opName" key="opKey"}
                            {php}
                            $checked = strval($opKey) === $configItem['value'] ? "checked":"";
                            {/php}
                            <input type="radio" name="{$configKey}" value="{$opKey}" title="{$opName}" {$checked}/>
                        {/foreach}
                    {/case}
                    {case value="textarea"}
                        <textarea class="layui-textarea" name="{$configKey}">{$configItem.value}</textarea>
                    {/case}
                    {case value="cdu"}
                        {php}
                            $dept = isset($configItem['param']['dept']) ? $configItem['param']['dept']:"false";
                            $user = isset($configItem['param']['user']) ? $configItem['param']['user']:"true";
                            $role = isset($configItem['param']['role']) ? $configItem['param']['role']:"false";
                            $dynamic = isset($configItem['param']['dynamic']) ? $configItem['param']['dynamic']:"false";
                            $rootdept = isset($configItem['param']['rootdept']) ? $configItem['param']['rootdept']:"1";
                            $multi = isset($configItem['param']['multi']) ? $configItem['param']['multi']:"true";
                        {/php}
                        {d:cdu name="$configKey" value="$configItem.value"
                            user="$user"
                            dept="$dept"
                            role="$role"
                            dynamic="$dynamic"
                            rootdept="$rootdept"
                            multi="$multi"
                        }请选择{/d:cdu}
                    {/case}
                    {default /}
                        <input class="layui-input" name="{$configKey}" value="{$configItem.value}"/>
                    {/switch}
                </div>
                <div class="layui-form-mid layui-word-aux">{$configItem.tip}</div>
            </div>
            {/foreach}
        </div>
    </div>
    {/foreach}
    <button class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
</form>

<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form;
        resetLabelWidth();
    });
    function resetLabelWidth() {
        var maxWidth = 0;
        $("#config-form .layui-form-label").each(function () {
            var width = $(this).width();
            if (width > maxWidth) {
                maxWidth = width;
            }
        });
        if (maxWidth > 0) {
            $("#config-form .layui-form-label").css("width", maxWidth + "px");
        } else {
            setTimeout("resetLabelWidth()", 200);
        }
    }
</script>
{/if}

{include file="common/pc/footer"/}